import fs from 'fs';

const ServersManagerConfig = {
	rootPort:80,
	rootStatic:'./public',
	https:{
		support:false,
		ssl:{
			key:'',
			cert:''
		}
	},
	xForwardIP:true,
	showRequestLogs:true,
	filterRequest,
	proxyRules:[
		/*
		* name
		* host : maybe a RegExp better, string then will be convert to RegExp
		* proxyTarget : host with protocol,event with a path,or a local dir path excepted
		* 
		*/
		{
			name:'all',
			host:'*',
			proxyTarget:'C:\\Users\\Administrator\\Desktop\\WXShop\\Koa2-base\\static\\dist'
		},
		{
			name:'mobile:8000',
			host:/^(?:(?:m|w{3})\.)?famanoder\.cn/,
			proxyTarget(req,res){
				if (~req.headers['user-agent'].toLowerCase().indexOf('mobile')) {
					return 'http://localhost:9000';
				};
			},
			xForwardIP:false,
			headers:{'x-host':'famanoder.cn'},
			cache:{maxAge:0}
		}
		
	]
}

function filterRequest(req,res){
	// intercept some request
}

export default ServersManagerConfig;